Valid for Sitecore
5.3.1
12.
Reference Types - Reference, Lookup, and Tree
Prev Next |
The complex field types, reference, lookup and tree stores the item the reference as text:
{0D45476E-F67C-4F14-9B4E-C26D53F6EC48}
It's possible to resolve the value by using implicit casting to
the Lookup object
// Reference, lookup, tree
public static string outReferenceLookup(Sitecore.Data.Items.Item item, string sFieldName)
{
System.Text.StringBuilder builder = new System.Text.StringBuilder();
Sitecore.Data.Fields.LookupField lookupField = item.Fields[sFieldName];
if (lookupField.TargetItem!=null)
{
builder.Append("lookupField.TargetItem.DisplayName : " + lookupField.TargetItem.DisplayName);
builder.Append("<br />");
builder.Append("lookupField.TargetItem.Paths.GetFriendlyUrl() : " + lookupField.TargetItem.Paths.GetFriendlyUrl());
builder.Append("<br />");
}
else
builder.Append(sFieldName + " does not link to a valid item");
return builder.ToString();
}
Result:
lookupField.TargetItem.DisplayName : updater
lookupField.TargetItem.Paths.GetFriendlyUrl() : /updater.html
Possible values:
Reference: Blank (null) or GUID
Prev Next